//JavaScript Framework 2.0 Code
try {
	Type.registerNamespace('com.yonyou.ncmm_pac_pda.WrDetailPageController');
	com.yonyou.ncmm_pac_pda.WrDetailPageController = function() {
		com.yonyou.ncmm_pac_pda.WrDetailPageController.initializeBase(this);
		this.initialize();
	}
	function com$yonyou$ncmm_pac_pda$WrDetailPageController$initialize() {
		//you can programing by $ctx API
		//get the context data through $ctx.get()
		//set the context data through $ctx.push(json)
		//set the field of the context through $ctx.put(fieldName, fieldValue)
		//get the parameter of the context through $ctx.param(parameterName)
		//Demo Code:
		//    var str = $ctx.getString();      //获取当前Context对应的字符串
		//    alert($ctx.getString())          //alert当前Context对应的字符串
		//    var json = $ctx.getJSONObject(); //获取当前Context，返回值为json
		//    json["x"] = "a";        //为当前json增加字段
		//    json["y"] = [];           //为当前json增加数组
		//    $ctx.push(json);            //设置context，并自动调用数据绑定
		//
		//    put方法需手动调用databind()
		//    var x = $ctx.get("x");    //获取x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.put("x", "b");     //设置x字段值
		//    $ctx.databind();            //调用数据绑定才能将修改的字段绑定到控件上
		//    var p1 = $param.getString("p1");   //获取参数p2的值，返回一个字符串
		//    var p2 = $param.getJSONObject("p2");   //获取参数p3的值，返回一个JSON对象
		//    var p3 = $param.getJSONArray("p3");   //获取参数p1的值，返回一个数组

		//your initialize code below...

	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$evaljs(js) {
		eval(js)
	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$listviewdefine0_onload(sender, args) {

	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$button1_onclick(sender, args) {
		// 跳转到扫描记录画面
		$view.open({
			viewid : "com.yonyou.ncmm_pac_pda.WrScranListPage",
			isKeep : "true"
		})
	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$button2_onclick(sender, args) {
		// 对于修改的数据进行暂存，保存到本地
		$ctx.dataCollect();
	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$button3_onclick(sender, args) {
		// 保存到本地，提交到nc端
		$ctx.dataCollect();
	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$imagebutton0_onclick(sender, args) {
		$scanner.open({
			bindfield : "barcode",
			callback : "myCallBack()"
		})
	}

	function myCallBack() {
		var barcode = $ctx.getString("barcode");
		$alert(barcode);
		//调用物料条码扫描接口
		var marjson = NCMMBarcodeParseUtil.parseMaterialBar(barcode);
		$alert(marjson);
		$ctx.push(marjson);
		$id("textbox0").set("value", barcode);
		$ctx.dataBind();
	}

	function com$yonyou$ncmm_pac_pda$WrDetailPageController$button0_onclick(sender, args) {
		$view.close();
	}



function com$yonyou$ncmm_pac_pda$WrDetailPageController$onchange(sender, args){
        $ctx.dataCollect();
        var barcode = $ctx.getString("barcode");
        //调用物料条码扫描接口
		var marjson = NCMMBarcodeParseUtil.parseMaterialBar(barcode);
		$alert(marjson);
		//$alert(marjson);
		$ctx.push(marjson);
		$id("textbox0").set("value", barcode);
		$ctx.dataBind();
}
function com$yonyou$ncmm_pac_pda$WrDetailPageController$onfocus(sender, args){
$id("textbox0").set("value", null);
}
com.yonyou.ncmm_pac_pda.WrDetailPageController.prototype = {
    onfocus : com$yonyou$ncmm_pac_pda$WrDetailPageController$onfocus,
    onchange : com$yonyou$ncmm_pac_pda$WrDetailPageController$onchange,
		button0_onclick : com$yonyou$ncmm_pac_pda$WrDetailPageController$button0_onclick,
		imagebutton0_onclick : com$yonyou$ncmm_pac_pda$WrDetailPageController$imagebutton0_onclick,
		button3_onclick : com$yonyou$ncmm_pac_pda$WrDetailPageController$button3_onclick,
		button2_onclick : com$yonyou$ncmm_pac_pda$WrDetailPageController$button2_onclick,
		button1_onclick : com$yonyou$ncmm_pac_pda$WrDetailPageController$button1_onclick,
		listviewdefine0_onload : com$yonyou$ncmm_pac_pda$WrDetailPageController$listviewdefine0_onload,
		initialize : com$yonyou$ncmm_pac_pda$WrDetailPageController$initialize,
		evaljs : com$yonyou$ncmm_pac_pda$WrDetailPageController$evaljs
	};
	com.yonyou.ncmm_pac_pda.WrDetailPageController.registerClass('com.yonyou.ncmm_pac_pda.WrDetailPageController', UMP.UI.Mvc.Controller);
} catch(e) {
	$e(e);
}
